from typing import Any

import yaml
import os


class ConfigService:

    def __init__(self):
        self.curPath = os.path.dirname(os.path.realpath(__file__))
        self.yamlPath = os.path.join(self.curPath, "config.yaml")
        f = open(self.yamlPath, 'r', encoding='utf-8')
        self.cfg = f.read()
        self.y_cfg = yaml.load(self.cfg, Loader=yaml.Loader)

    def __new__(cls, *args, **kwargs):
        if not hasattr(cls, '_inst'):
            cls._inst = super(ConfigService, cls).__new__(cls, *args, **kwargs)
        return cls._inst

    def __getitem__(self, item):
        return self.y_cfg.get(item)



